package cn.tmall.pojo;

public class User {
    private Integer id;

    private String name;

    private String password;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    //返回一个匿名
    public String getAnonymousName() {
        if (null == name)
            return null;
        else if (name.length() == 1)
            return "*";
        else if (name.length() == 2)
            return name.substring(0, 1) + "*";
        char[] arr = name.toCharArray();
        for (int i = 1; i < arr.length - 1; ++i)
            arr[i] = '*';
        return new String(arr);
    }
}